from psycopg2.extensions import adapt, register_adapter, AsIs 

## Adapter function to sanitize table name input strings It will only
#  pass a good string if it is in the tuple of tables

def adapt_table(table):
    if table in ('accel_x', 'accel_y', 'humidity', 'ir', 'light', 'mag_x', 'mag_y', 'temperature', 'motes', 'sensors', 'mote_conf'):
        return AsIs(table)
    else:
        return 'No Touchy My DB'

register_adapter(str, adapt_table)
